package day04;

import java.util.Random;
import java.util.Scanner;

public class Day04StandardExercise3 {
    public static void main(String[] args) {
        /*
        CommandBySwitch命令解析程序：

要求：接收用户输入的命令，依据命令做不同的操作
         */
        /*
        int num=1;
        switch (num){
            case 1:
                System.out.println("查询余额");
                break;
            case 2:
                System.out.println("取款");
                break;
            case 3:
                System.out.println("存款");
                break;
            default:
                System.out.println("输入错误，请重新输入");
        }

         */
        /*
        Guessing猜数字之while版：

要求：随机生成一个数，由用户来猜，猜不对则反复猜，并给出大小提示，猜对的则结束，用while来实现。
         */
        /*
        Scanner scanner=new Scanner(System.in);
        int num=(int)(Math.random()*1000+1);
        System.out.println(num);
        System.out.println("请输入要猜的值：");
        int guess=scanner.nextInt();//循环变量
        while (num!=guess){
            if (guess>num){
                System.out.println("猜大了");
                guess=scanner.nextInt();
            }else {
                System.out.println("猜小了");
                guess=scanner.nextInt();
            }
        }
        System.out.println("猜对了");

         */
        /*
        Guessing猜数字之do...while版

要求：随机生成一个数，由用户来猜，猜不对则反复猜，并给出大小提示，猜对的则结束，用do...while来实现。
         */
        /*
        int random=(int)(Math.random()*1000+1);
        System.out.println(random);
        Scanner scanner=new Scanner(System.in);
        int guess;
        do {
            System.out.println("请输入要猜的数字：");
             guess = scanner.nextInt();
            if (random>guess){
                System.out.println("猜小了");
            }else if (random<guess){
                System.out.println("猜大了");
            }else {
                System.out.println("猜对了");
            }
        }while (random!=guess);

         */
        /*
        for循环：输出5次"行动是成功的阶梯"、输出9的乘法表(1到9、1/3/5/7/9、9到1)
         */
        /*
        for (int i=0;i<5;i++){
            System.out.println("行动是成功的阶梯");
        }
        for (int i=1;i<=9;i++){
            System.out.println(i+"*9="+i*9);
        }
        for (int i=1;i<=9;i+=2){
            System.out.println(i+"*9="+i*9);
        }
        for (int i=9;i>=1;i--){
            System.out.println(i+"*9="+i*9);
        }

         */
        /*
        接收用户输入的一个整数num，判断它的正负零值，正数则输出"+"，负数则输出"-"，0则输出"0"
         */
        /*
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入一个整数");
        int random = scanner.nextInt();
        if (random>0){
            System.out.println("+");
        }else if (random<0){
            System.out.println("-");
        }else {
            System.out.println("0");
        }

         */
        /*
        接收用户输入的年份year和月份month，计算该年该月的天数，并输出
         */
/*
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入年份");
       int year= scanner.nextInt();
        System.out.println("请输入月份");
        int mouth=scanner.nextInt();
        if (year%4==0&&year%100!=0 || year%400==0){

            switch (mouth){
                case 1:

                case 3:

                case 5:

                case 7:

                case 8:

                case 10:

                case 12:
                    System.out.println(year+"年为闰年,"+mouth+"月有31天");
                    break;
                case 4:

                case 6:

                case 9:

                case 11:
                    System.out.println(year+"年为闰年,"+mouth+"月有30天");
                    break;

                case 2:
                    System.out.println(year+"年为闰年,"+mouth+"月有29天");
                    break;
                default:
                    System.out.println("月份输入有误");




            }

        }else {
            switch (mouth){
                case 1:

                case 3:

                case 5:

                case 7:

                case 8:

                case 10:

                case 12:
                    System.out.println(year+"年为平年,"+mouth+"月有31天");
                    break;
                case 4:

                case 6:

                case 9:

                case 11:
                    System.out.println(year+"年为平年,"+mouth+"月有30天");
                    break;
                case 2:
                    System.out.println(year+"年为平年,"+mouth+"月有28天");
                    break;
                default:
                    System.out.println("月份输入有误");




            }

        }

 */
        /*
        利用循环语句while计算数字1到100的和，并输出
         */
        /*
        int i=1;
        int sum=0;
        while (i<=100){
            i++;
            sum+=i;

        }
        System.out.println(sum);

         */
        /*
        输出1900到2023年之间所有的闰年(每够10个年份，换一行)
         */
        int count=0;
            for (int year=1900;year<=2023;year++){
                if (year%4==0&& year%100!=0 || year%400==0){
                   count++;
                    System.out.print(year+" ");
                    if (count%10==0){
                        System.out.println();
                    }
                }

            }




    }


}
